	#include<iostream>
	using namespace std;
	int arr[1010];
	void fun1()
	{
		int k = 1;
		for (int i = 'A'; i <= 'Z'; i++) {
			arr[i] = k++;
		}
	}
	int fun(string s)
	{
		int sum = 1;
		for (int i = 0; i < s.size(); i++) {
			sum *= arr[s[i]];
		}
		return sum;
	}
	int main()
	{
		string arr1, arr2;
		cin >> arr1;
		cin >> arr2;
		fun1();
		int ret1 = fun(arr1) % 47;
		int ret2 = fun(arr2) % 47;
		if (ret1 == ret2) {
			cout << "GO" << endl;
		}
		else {
			cout << "STAY" << endl;
		}
		return 0;
	}